<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String bp = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String __MANAGER = bp+"admin/";
String __SHOWMAINVIEW = __MANAGER+"showModule.do";
String __CREATEMENUBUTTON = __MANAGER+"createMenuButton.do";
%>
<!DOCTYPE html>
<html>
  <head>
    <title>SWIFT4J快速开发平台</title>
  </head>
  
<body>
	<div class="d-1">
		<h2 class="h2-ac">一般资料</h2>
		<div class="d-b1">
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="docSave()">保存</a>
		</div>
		<div style="padding-top: 10px;">
			<form id="docForm" name="docForm" action="<%=__MANAGER %>liverDoc_commonSave.do" method="post" onsubmit="return aaa()">
				<input type="hidden" name="patientDoc.docId" value="${patientDoc.docId }">
				<table border="1" cellspacing="0" cellpadding="15" class="fs16">
					<tr>
					    <td><label id="mgDoc.docNo_Label">序号</label></td>
					    <td><input type="text" readonly="readonly" name="patientDoc.docNo" value="${patientDoc.docNo }"></td>
						<td><label id="mgDoc.name_Label" for="name">姓名</label></td>
					    <td><input type="text" name="patientDoc.name" value="${patientDoc.name }" ></td>
						<td><label id="mgDoc.sex_Label">性别</label></td>
					    <td>
					    	<!-- 1:男 2：女 -->
					    	<input type="radio" name="patientDoc.sex" value="1" <c:if test="${patientDoc.sex == 1 }"> checked="checked"</c:if> >男
					    	<input type="radio" name="patientDoc.sex" value="2" <c:if test="${patientDoc.sex == 2 }"> checked="checked"</c:if> >女
					    </td>
					</tr>
					<tr>
						<td><label id="mgDoc.surveyDay_Label">调查时间</label></td>
					    <td colspan="5"><input type="text" name="patientDoc.surveyDay" value="${patientDoc.surveyDay }"></td>
					</tr>
					<tr>
						<td><label id="mgDoc.birthday_Label">出生日期</label></td>
					    <td><input type="text" name="patientDoc.birthday" value="${patientDoc.birthday }" ></td>
						<td><label id="mgDoc.age_Label">年龄</label></td>
					    <td colspan="3"><input type="text" name="patientDoc.age" value="${patientDoc.age }" >岁</td>
					</tr>
					<tr>
						<!-- 1-未婚；2-已婚；3-离婚；4-丧偶 -->
						<td><label id="mgDoc.marriy_Label">婚况</label></td>
					    <td colspan="5">
					    	<input type="radio" name="patientDoc.marriy" value="1" <c:if test="${patientDoc.marriy == 1 }"> checked="checked"</c:if> >未婚
					    	<input type="radio" name="patientDoc.marriy" value="2" <c:if test="${patientDoc.marriy == 2 }"> checked="checked"</c:if> >已婚
					    	<input type="radio" name="patientDoc.marriy" value="3" <c:if test="${patientDoc.marriy == 3 }"> checked="checked"</c:if> >离婚
					    	<input type="radio" name="patientDoc.marriy" value="4" <c:if test="${patientDoc.marriy == 4 }"> checked="checked"</c:if> >丧偶
					    </td>
					</tr>
					<tr>
						<!-- 1-工人；□2-农民；□3-干部；□4-退休；□5-其他 -->
						<td><label id="mgDoc.job_Label">职业</label></td>
					    <td colspan="5">
					    	<input type="radio" name="patientDoc.job" value="1" <c:if test="${patientDoc.job == 1 }"> checked="checked"</c:if> >工人
					    	<input type="radio" name="patientDoc.job" value="2" <c:if test="${patientDoc.job == 2 }"> checked="checked"</c:if> >农民
					    	<input type="radio" name="patientDoc.job" value="3" <c:if test="${patientDoc.job == 3 }"> checked="checked"</c:if> >干部
					    	<input type="radio" name="patientDoc.job" value="4" <c:if test="${patientDoc.job == 4 }"> checked="checked"</c:if> >退休
					    	<input type="radio" name="patientDoc.job" value="5" <c:if test="${patientDoc.job == 5 }"> checked="checked"</c:if> >其他
					    </td>
					</tr>
					<tr>
						<!-- 1-汉族；□2-少数民族 -->
						<td><label id="mgDoc.nation_Label">民族</label></td>
					    <td colspan="5">
					    	<input type="radio" name="patientDoc.nation" value="1" <c:if test="${patientDoc.nation == 1 }"> checked="checked"</c:if> >汉族
					    	<input type="radio" id="nation2" name="patientDoc.nation" value="2" <c:if test="${patientDoc.nation == 2 }"> checked="checked"</c:if> >少数民族
					    	(<input type="text" name="patientDoc.nationality" value="${patientDoc.nationality }" >族)
					    </td>
					</tr>
					<tr>
						<td><label id="mgDoc.disCourse_Label">病程</label></td>
					    <td><input type="text" name="patientDoc.disCourse" value="${patientDoc.disCourse }" >年</td>
						<td><label id="mgDoc.stature_Label">身高</label></td>
					    <td><input type="text" name="patientDoc.stature" value="${patientDoc.stature }">cm</td>
						<td><label id="mgDoc.weight_Label">体重</label></td>
					    <td><input type="text" name="patientDoc.weight" value="${patientDoc.weight }">kg</td>
					</tr>
					<tr>
						<!-- □1-A型；□2-B型；□3-AB型；□4-O型 -->
						<td><label id="mgDoc.bloodType_Label">血型</label></td>
					    <td colspan="5">
					    	<input type="radio" name="patientDoc.bloodType" value="1" <c:if test="${patientDoc.bloodType == 1 }"> checked="checked"</c:if> >A型
					    	<input type="radio" name="patientDoc.bloodType" value="2" <c:if test="${patientDoc.bloodType == 2 }"> checked="checked"</c:if> >B型
					    	<input type="radio" name="patientDoc.bloodType" value="3" <c:if test="${patientDoc.bloodType == 3 }"> checked="checked"</c:if> >AB型
					    	<input type="radio" name="patientDoc.bloodType" value="4" <c:if test="${patientDoc.bloodType == 4 }"> checked="checked"</c:if> >O型
					    </td>
					</tr>
					<tr>
						<!-- □1-住院病人（住院号：□□□□□□□）；□2-门诊病人 -->
						<td><label id="mgDoc.disSource_Label">病人来源</label></td>
					    <td colspan="5">
					    	<input type="radio" id="disSource" name="patientDoc.disSource" value="1" <c:if test="${patientDoc.disSource == 1 }"> checked="checked"</c:if> >住院病人
					    	(住院号<input type="text" id="disSourceNo" name="patientDoc.disSourceNo" value="${patientDoc.disSourceNo }">)
					    	<input type="radio" name="patientDoc.disSource" value="2" <c:if test="${patientDoc.disSource == 2 }"> checked="checked"</c:if> >门诊病人
					    </td>
					</tr>
					<tr>
						<td><label id="mgDoc.homeAddress_Label">家庭住址</label></td>
					    <td colspan="5"><input type="text" size="60" name="patientDoc.homeAddress" value="${patientDoc.homeAddress }"></td>
					</tr>
					<tr>
						<td><label id="mgDoc.homePhone_Label">住宅电话</label></td>
					    <td colspan="5"><input type="text" size="60" name="patientDoc.homePhone" value="${patientDoc.homePhone }"></td>
					</tr>
					<tr>
						<td><label id="mgDoc.inputDate_Label">录入时间</label></td>
					    <td><input type="text" readonly="readonly" name="patientDoc.inputDate" value="${patientDoc.inputDate }"></td>
						<td><label id="mgDoc.inputUserName_Label">录入人</label></td>
					    <td colspan="3"><input type="text" readonly="readonly" name="patientDoc.inputUserName" value="${patientDoc.inputUserName }"></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript">
	
		$(function() {
			$("#docForm").validate({
				rules: {
					"patientDoc.name": "required",
					"patientDoc.sex": "required",
					"patientDoc.birthday": "required",
					"patientDoc.nationality": {
						required: "#nation2:checked"
					},
					"patientDoc.disCourse": "required"
				}
			});
			
			//调查时间
			$('input[name="patientDoc.surveyDay"]').datebox();
			
			//生日
			$('input[name="patientDoc.birthday"]').datebox({
				onSelect: function(date) {
					birthdayChange(date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate());
				}
			});
		});
	
		function docSave() {
			if(!$("#docForm").valid()) {
				return;
			}
			$("#docForm").ajaxSubmit({
				type: 'post',
				success: function(data) {
					if(data['rtnCode'] == 'success') {
						S4J.utils.showMessage(data.rtnMsg);
					}
					$.ajax({
						url : __SHOWMAINVIEW+'_mduno=docmgr_liverdocmgr_docEdit&docId='+data.docId,
						type : "GET",
						contentType : "application/x-www-form-urlencoded;charset=utf-8",
						success : function(_html) {
							$('#docEditWindow').window({
								width: 500,
								height: 150,
								modal: true,
								title: '编辑档案',
								minimizable: false,
								maximizable: false,
								maximized: true,
								content: _html
							});
						}
					});
				}
			});
			
			/*$(docForm).form('submit',{
				url: __MANAGER+'liverDoc_commonSave.do',
				success: function(data){
					var json = jQuery.parseJSON(data);
					if(json.rtnCode == 'success') {
						S4J.utils.showMessage(json.rtnMsg);
					}
					$.ajax({
						url : __SHOWMAINVIEW+'_mduno=docmgr_liverdocmgr_docEdit&docId='+json.docId,
						type : "GET",
						contentType : "application/x-www-form-urlencoded;charset=utf-8",
						success : function(_html) {
							$('#docEditWindow').window({
								width: 500,
								height: 150,
								modal: true,
								title: '编辑档案',
								minimizable: false,
								maximizable: false,
								maximized: true,
								content: _html
							});
						}
					});
				},
				onLoadError: function() {
					S4J.utils.showMessage('保存失败，请重试');
				}
			});*/
		}
		
		function birthdayChange(t) {
			var age = S4J.utils.ages(t);
			if(age > -1) {
				$('input[name="patientDoc.age"]').val(age);
			}
		}
	</script>
</body>
</html>
